package com.yaozheng.vocationaltraining.service.impl;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EBean;

import com.yaozheng.vocationaltraining.iview.ITokenBaseView;
import com.yaozheng.vocationaltraining.service.IntegralDetailsService;
import com.yaozheng.vocationaltraining.utils.Constants;
import com.yaozheng.vocationaltraining.utils.ErrorUtils;
import com.yaozheng.vocationaltraining.utils.http.okhttp.OkHttpClientManager;

@EBean
public class IntegralDetailsServiceImpl implements IntegralDetailsService {
    ITokenBaseView iTokenBaseView;

    @Override
    public void init(ITokenBaseView iTokenBaseView) {
        this.iTokenBaseView = iTokenBaseView;
    }

    @Background
    @Override
    public void integralDetailsList(int type, int offset) {
        try {

            OkHttpClientManager.getInstance().get(
                    Constants.ROOTURL + (type == 0 ? "/user/score/detail" : "/user/experience/detail") + "?offset=" + offset,
                    iTokenBaseView.getToken(), iTokenBaseView);
        } catch (Exception e) {
            ErrorUtils.outErrorLog(e);
            if (iTokenBaseView.isResponseResult()) {
                iTokenBaseView
                        .responseError(ErrorUtils.SERVER_CONNECTION_ERROR);
            }

        }
    }

}
